<style type="text/css"> 
<!--
table {
  border-collapse: collapse
}
td
{
padding-right:15px;
border-bottom:1px solid #CDD3E0;
border-top:1px solid #FFFFFF;
}



-->
</style>
<?php 
		//-------------------------------------------------------------------------------------------
		//----------------------------- PAGE DE GARDE          --------------------------------------
		//-------------------------------------------------------------------------------------------
		
		//echo "<pre>";
		//print_r($total_forfait_options);
		//echo "</pre>";
		
		//echo count($facture);
		//echo $tab_option[0]['prix'];
		
				$total_ligne=0;
		//calcul du total de la facture
		for($n=0;$n<count($facture);$n++)
			{ 
			
				$facture_total_forfait += $total_forfait[$n];
				$facture_total_mobile += $tab_mobile[$n]['prix'] ;
				if(date("m/Y",$date_souscription[$n]) == date("m/Y",$debut_mois_prec) and $facture_faite[$n]==0)
				{
				$facture_forfait_plein += $total_forfait_plein[$n];
				}
				
				if(isset($tab_option[$n]))
					{
						for($i=0;$i<count($tab_option[$n]);$i++)
						{ 
								
							$facture_total_option += $tab_option[$n][$i]['prix'] ;
							if(date("m/Y",$date_souscription[$n]) == date("m/Y",$debut_mois_prec) and $facture_faite[$n]==0)
							{
							$facture_total_option += $tab_option[$n][$i]['plein'];
							}
						}
					}
				
			}

		//calcul de la remise et du total de la facture	
		
		//$facture_total_forfait = $facture_total_forfait-(($facture_total_forfait*$tab_forfait[0]['remise'])/100);	
		//$facture_total_ht = $facture_total_forfait+$facture_total_mobile+$facture_total_option+$facture_total_HF;
		
				
		$facture_total_ht = $facture_total_forfait+$facture_total_option+$facture_total_mobile+$facture_total_HF+$facture_forfait_plein;
		
?>
<br /><br /><br /><br />

<table width="560" align="left" >
    <tr >
        <td width="460" align="left"><b>Services et produits</b></td>
        <td width="100" align="center"><b>Montant € HT</b></td>
    </tr>
    <tr>
        <td>Total de vos services et options</td>
        <td align="right"><?php echo str_replace(".",",",number_format($facture_total_forfait+$facture_total_option+$facture_total_mobile+$facture_forfait_plein,2)); ?></td>
    </tr>
    <tr>
        <td>Total de vos consommations</td>
        <td align="right"><?php echo str_replace(".",",",number_format($facture_total_HF,2)); ?></td>
    </tr>
    <tr>
        <td align="right"><b>Total HT</b></td>
        <td align="right"><b><?php echo str_replace(".",",",number_format($facture_total_ht,2)); ?></b></td>
    </tr>
    <tr>
        <td align="right">TVA 20%</td>
        <td align="right"><?php echo str_replace(".",",",number_format(($facture_total_ht*0.2),2)); ?></td>
    </tr>
    <tr>
        <td align="right"><b>Total TTC</b></td>
        <td align="right"><b><?php echo str_replace(".",",",number_format(($facture_total_ht*1.2),2)); ?></b></td>
    </tr>
</table>
        
<br /><br /><br /><br />

<?php 
//affichage du mode de paiement 
if($donneesclients['mode_paiement']=="Prélévement")
{
	echo "Le montant de votre facture sera prélevé le ".date("d/m/Y", mktime(0, 0, 0, date("m"),10, date("Y"))).".";
	echo "<br> sur le compte ".$donneesclients['code_etablissement']." ".$donneesclients['code_guichet']." ".$donneesclients['num_compte']." ".$donneesclients['rib'];
}
elseif($donneesclients['mode_paiement']=="Chèque")
{
	echo "Paiement par Chèque avant le ".date("d/m/Y",mktime(0, 0, 0, date("m"),10, date("Y"))).".";
}
elseif($donneesclients['mode_paiement']=="Mandat administratif")
{
	echo "Paiement par Mandat administratif avant le ".date("d/m/Y",mktime(0, 0, 0, date("m"),10, date("Y"))).".<br>";
	echo RIB;
}
elseif($donneesclients['mode_paiement']=="Virement")
{
	echo "Paiement par Virement avant le ".date("d/m/Y",mktime(0, 0, 0, date("m"),10, date("Y"))).".<br>";
	echo RIB;
}
?>
        
<?php 
$fichier = "facture_temp/".date("mY")."/Mobile-".$donneesclients['code_client_hto']."-".date("mY").".pdf";
$total = number_format($facture_total_ht,2);
$date = date("Y-m-d H:i:s");



//insertion dans la base
//if(is_file($fichier)) 	//s'il existe -> faire un update
//{
//$requete = $bdd->prepare("UPDATE `admin_facture` SET total_facturation = '".$total."', date = '".$date."' WHERE facture = '".$fichier."' ");
//}else{					//sinon l'ins�rer
$requete = $bdd->prepare("INSERT INTO `admin_facture` (`id`, `id_client`, `nom`, `total_facturation`, `date`, `type`, `facture`) VALUES ('','".$id_client."','".$nom."', '".$total."','".$date."','mobile' ,'".$fichier."') ");
//}
$requete->execute() or exit(print_r($bdd->errorInfo()));
?>
